home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 May: Tool Chest / Developer CD Series Tool Chest (Apple Computer)(May 1999).iso / Tool Chest / Development Kits / MPW etc / MPW-GM / MPW / Examples / PPCExamples / CPlusExamples / CPlusTESample / TESample.r < prev    next >
Encoding:
Text File  |  1998-12-03  |  7.4 KB  |  336 lines  |  [TEXT/MPS ]

  1. /*------------------------------------------------------------------------------
  2. #
  3. #    Apple Macintosh Developer Technical Support
  4. #
  5. #    MultiFinder-Aware Simple TextEdit Sample Application
  6. #
  7. #    CPlusTESample
  8. #
  9. #    TESample.r    -    Rez source
  10. #
  11. #    Copyright © 1989, 1994, 1998 Apple Computer, Inc.
  12. #    All rights reserved.
  13. #
  14. #    Versions:
  15. #            2.11                    06/98        compatible with 3.1 interfaces
  16. #           2.10                    01/94       for PowerPC
  17. #            2.00                    03/93        for PowerPC
  18. #            1.10                     07/89
  19. #            1.00                     04/89
  20. #
  21. #    Components:
  22. #            CPlusTESample.make        July 9, 1989
  23. #            TApplicationCommon.h    July 9, 1989
  24. #            TApplication.h            July 9, 1989
  25. #            TDocument.h                July 9, 1989
  26. #            TECommon.h                July 9, 1989
  27. #            TESample.h                July 9, 1989
  28. #            TEDocument.h            July 9, 1989
  29. #            TESample.cp                July 9, 1989
  30. #            TESample.r                July 9, 1989
  31. #
  32. #    CPlusTESample is an example application that demonstrates
  33. #    how to initialize the commonly used toolbox managers,
  34. #    operate successfully under MultiFinder, handle desk
  35. #    accessories and create, grow, and zoom windows. The
  36. #    fundamental TextEdit toolbox calls and TextEdit autoscroll
  37. #    are demonstrated. It also shows how to create and maintain
  38. #    scrollbar controls. 
  39. #
  40. #    This version of TESample has been substantially reworked in
  41. #    C++ to show how a "typical" object oriented program could
  42. #    be written. To this end, what was once a single source code
  43. #    file has been restructured into a set of classes which
  44. #    demonstrate the advantages of object-oriented programming.
  45. #
  46. ------------------------------------------------------------------------------*/
  47.  
  48. #include "SysTypes.r"
  49. #include "Types.r"
  50.  
  51. #include "TECommon.h"
  52.  
  53. resource 'vers' (1) {
  54.     0x02, 0x00, release, 0x00,
  55.     verUS,
  56.     "2.10",
  57.     "2.10, Copyright © 1989, 1994 Apple Computer, Inc."
  58. };
  59.  
  60. /* we use an MBAR resource to conveniently load all the menus */
  61.  
  62. resource 'MBAR' (rMenuBar, preload) {
  63.     { mApple, mFile, mEdit, mDebug };        /* three menus + debug */
  64. };
  65.  
  66.  
  67. resource 'MENU' (mApple, preload) {
  68.     mApple, textMenuProc,
  69.     0b1111111111111111111111111111101,    /* disable dashed line, enable About and DAs */
  70.     enabled, apple,
  71.     {
  72.         "About CPlusTESample…",
  73.             noicon, nokey, nomark, plain;
  74.         "-",
  75.             noicon, nokey, nomark, plain
  76.     }
  77. };
  78.  
  79. resource 'MENU' (mFile, preload) {
  80.     mFile, textMenuProc,
  81.     0b0000000000000000000100000000000,    /* enable Quit only, program enables others */
  82.     enabled, "File",
  83.     {
  84.         "New",
  85.             noicon, "N", nomark, plain;
  86.         "Open",
  87.             noicon, "O", nomark, plain;
  88.         "-",
  89.             noicon, nokey, nomark, plain;
  90.         "Close",
  91.             noicon, "W", nomark, plain;
  92.         "Save",
  93.             noicon, "S", nomark, plain;
  94.         "Save As…",
  95.             noicon, nokey, nomark, plain;
  96.         "Revert",
  97.             noicon, nokey, nomark, plain;
  98.         "-",
  99.             noicon, nokey, nomark, plain;
  100.         "Page Setup…",
  101.             noicon, nokey, nomark, plain;
  102.         "Print…",
  103.             noicon, nokey, nomark, plain;
  104.         "-",
  105.             noicon, nokey, nomark, plain;
  106.         "Quit",
  107.             noicon, "Q", nomark, plain
  108.     }
  109. };
  110.  
  111. resource 'MENU' (mEdit, preload) {
  112.     mEdit, textMenuProc,
  113.     0b0000000000000000000000000000000,    /* disable everything, program does the enabling */
  114.     enabled, "Edit",
  115.      {
  116.         "Undo",
  117.             noicon, "Z", nomark, plain;
  118.         "-",
  119.             noicon, nokey, nomark, plain;
  120.         "Cut",
  121.             noicon, "X", nomark, plain;
  122.         "Copy",
  123.             noicon, "C", nomark, plain;
  124.         "Paste",
  125.             noicon, "V", nomark, plain;
  126.         "Clear",
  127.             noicon, nokey, nomark, plain
  128.     }
  129. };
  130.  
  131. resource 'MENU' (mDebug, preload) {
  132.     mDebug, textMenuProc,
  133.     0b0000000000000000000000000000001,    /* enable debug item */
  134.     enabled, "Debug",
  135.     {
  136.         "Enter Debugger…",
  137.             noicon, nokey, nomark, plain
  138.     }
  139. };
  140.  
  141.  
  142.  
  143. /* this ALRT and DITL are used as an About screen */
  144.  
  145. resource 'ALRT' (rAboutAlert, purgeable) {
  146.     {40, 20, 160, 330 }, rAboutAlert, {
  147.         OK, visible, silent;
  148.         OK, visible, silent;
  149.         OK, visible, silent;
  150.         OK, visible, silent
  151.     },
  152.     centerMainScreen
  153. };
  154.  
  155. resource 'DITL' (rAboutAlert, purgeable) {
  156.     { /* array DITLarray: 5 elements */
  157.         /* [1] */
  158.         {88, 224, 108, 304},
  159.         Button {
  160.             enabled,
  161.             "OK"
  162.         },
  163.         /* [2] */
  164.         {8, 8, 24, 304 },
  165.         StaticText {
  166.             disabled,
  167.             "MultiFinder-Aware C++ TextEdit Application"
  168.         },
  169.         /* [3] */
  170.         {32, 8, 48, 304},
  171.         StaticText {
  172.             disabled,
  173.             "Copyright © 1989, 1993 Apple Computer, Inc."
  174.         },
  175.         /* [4] */
  176.         {56, 8, 72, 136},
  177.         StaticText {
  178.             disabled,
  179.             "Brought to you by:"
  180.         },
  181.         /* [5] */
  182.         {80, 24, 112, 167},
  183.         StaticText {
  184.             disabled,
  185.             "Macintosh Developer Technical Support"
  186.         }
  187.     }
  188. };
  189.  
  190. /* this ALRT and DITL are used as an error screen */
  191.  
  192. resource 'ALRT' (rUserAlert, purgeable) {
  193.     {40, 20, 150, 260},
  194.     rUserAlert,
  195.     {    /* array: 4 elements */
  196.         /* [1] */
  197.         OK, visible, silent,
  198.         /* [2] */
  199.         OK, visible, silent,
  200.         /* [3] */
  201.         OK, visible, silent,
  202.         /* [4] */
  203.         OK, visible, silent
  204.     },
  205.     centerMainScreen
  206. };
  207.  
  208. resource 'DITL' (rUserAlert, purgeable) {
  209.     { /* array DITLarray: 3 elements */
  210.         /* [1] */
  211.         {80, 150, 100, 230},
  212.         Button {
  213.             enabled,
  214.             "OK"
  215.         },
  216.         /* [2] */
  217.         {10, 60, 60, 230},
  218.         StaticText {
  219.             disabled,
  220.             "Error. ^0."
  221.         },
  222.         /* [3] */
  223.         {8, 8, 40, 40},
  224.         Icon {
  225.             disabled,
  226.             2
  227.         }
  228.     }
  229. };
  230.  
  231. resource 'WIND' (rDocWindow, preload, purgeable) {
  232.     {64, 60, 314, 460},
  233.     zoomDocProc, invisible, goAway, 0x0, "untitled", noAutoCenter
  234. };
  235.  
  236.  
  237. resource 'CNTL' (rVScroll, preload, purgeable) {
  238.     {-1, 385, 236, 401},
  239.     0, visible, 0, 0, scrollBarProc, 0, ""
  240. };
  241.  
  242.  
  243. resource 'CNTL' (rHScroll, preload, purgeable) {
  244.     {235, -1, 251, 386},
  245.     0, visible, 0, 0, scrollBarProc, 0, ""
  246. };
  247.  
  248. resource 'STR#' (kTEDocErrStrings, purgeable) {
  249.     {
  250.     "Not enough memory to run TESample";
  251.     "Not enough memory to do Cut";
  252.     "Cannot do Cut";
  253.     "Cannot do Copy";
  254.     "Cannot exceed 32,000 characters with Paste";
  255.     "Not enough memory to do Paste";
  256.     "Cannot create window";
  257.     "Cannot exceed 32,000 characters";
  258.     "Cannot do Paste"
  259.     }
  260. };
  261.  
  262. /* here is the quintessential MultiFinder friendliness device, the SIZE resource */
  263.  
  264. resource 'SIZE' (-1) {
  265.     dontSaveScreen,
  266.     acceptSuspendResumeEvents,
  267.     enableOptionSwitch,
  268.     canBackground,        /* we can background; we don't currently, but our sleep value */
  269.                         /* guarantees we don't hog the Mac while we are in the background */
  270.     multiFinderAware,    /* this says we do our own activate/deactivate; don't fake us out */
  271.     backgroundAndForeground, /* this is definitely note a background-only application! */
  272.     dontGetFrontClicks,    /* change this is if you want "do first click" behavior like the Finder */
  273.     ignoreChildDiedEvents,
  274.     is32BitCompatible,
  275.     reserved, reserved, reserved, reserved,
  276.     reserved, reserved, reserved,
  277.     kPrefSize * 1024,
  278.     kMinSize * 1024
  279. };
  280.  
  281.  
  282. type 'MOOT' as 'STR ';
  283.  
  284.  
  285. resource 'MOOT' (0) {
  286.     "MultiFinder-Aware TextEdit Sample Application"
  287. };
  288.  
  289.  
  290. resource 'BNDL' (128) {
  291.     'MOOT',
  292.     0,
  293.     {
  294.         'ICN#',
  295.         {
  296.             0, 128
  297.         },
  298.         'FREF',
  299.         {
  300.             0, 128
  301.         }
  302.     }
  303. };
  304.  
  305.  
  306. resource 'FREF' (128) {
  307.     'APPL',
  308.     0,
  309.     ""
  310. };
  311.  
  312.  
  313. resource 'ICN#' (128) {
  314.     { /* array: 2 elements */
  315.         /* [1] */
  316.         $"04 30 40 00 0A 50 A0 00 0B 91 10 02 08 22 08 03"
  317.         $"12 24 04 05 20 28 02 09 40 10 01 11 80 0C 00 A1"
  318.         $"80 03 FF C2 7E 00 FF 04 01 00 7F 04 03 00 1E 08"
  319.         $"04 E0 00 0C 08 E0 00 0A 10 E0 00 09 08 C0 00 06"
  320.         $"04 87 FE 04 02 88 01 04 01 88 00 84 00 88 00 44"
  321.         $"00 88 00 44 00 88 00 C4 01 10 01 88 02 28 03 10"
  322.         $"01 C4 04 E0 00 02 08 00 73 BF FB EE 4C A2 8A 2A"
  323.         $"40 AA AA EA 52 AA AA 24 5E A2 8A EA 73 BE FB 8E",
  324.         /* [2] */
  325.         $"04 30 40 00 0E 70 E0 00 0F F1 F0 02 0F E3 F8 03"
  326.         $"1F E7 FC 07 3F EF FE 0F 7F FF FF 1F FF FF FF BF"
  327.         $"FF FF FF FE 7F FF FF FC 01 FF FF FC 03 FF FF F8"
  328.         $"07 FF FF FC 0F FF FF FE 1F FF FF FF 0F FF FF FE"
  329.         $"07 FF FF FC 03 FF FF FC 01 FF FF FC 00 FF FF FC"
  330.         $"00 FF FF FC 00 FF FF FC 01 FF FF F8 03 EF FF F0"
  331.         $"01 C7 FC E0 00 03 F8 00 73 BF FB EE 7F BE FB EE"
  332.         $"7F BE FB EE 7F BE FB E4 7F BE FB EE 73 BE FB 8E"
  333.     }
  334. };
  335.  
  336.